# Create your views here.
from django.http import *
from django.template import *
from django.shortcuts import *
from django.template.loader import get_template
from l2ldjango.apps.lawschool.models import *

def checkLawschool(request):
    emailaddress=request.POST['emailaddress'];
    incoming_domain=request.POST['emailaddress'].index('@')+1
    domain_name=emailaddress[incoming_domain:]    
    lawschools=lawschool.objects.all();
    addressvalid=False;
    for ls in lawschools:
        if ls.example_email==domain_name:
            addressvalid=True
            
    return HttpResponse(addressvalid)
        
def getLawschoolByEmail(email):
    emailaddress=email;
    incoming_domain=emailaddress.index('@')+1
    domain_name=emailaddress[incoming_domain:]    
    lawschools=lawschool.objects.all();
    addressvalid=False;
    for ls in lawschools:
        if ls.example_email==domain_name:
            return ls.school
            
    return 'school not found in database'        
            